package com.wnxy;


import feign.Logger;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

@EnableCircuitBreaker // 启用熔断器
@EnableFeignClients("com.wnxy.sddfp.client.bank")// 启用Feign
@MapperScan("com.wnxy.sddfp.system.mapper")
@SpringBootApplication
@ComponentScan(basePackages = {
        "com.wnxy.sddfp.system",
        "com.wnxy.sddfp.common",
        "com.wnxy.sddfp.client.bank.api.fallback"
})
public class SystemApplication {
    public static void main(String[] args) {
        SpringApplication.run(SystemApplication.class, args);
    }

    // 消息的转换器，支持发送消息时候传入对象，会自动把对象转换为json格式
    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }

    @Bean
    public Logger.Level loggerLevel() {
        return Logger.Level.FULL;
    }

    // 在启动类或配置类中注入负载均衡策略对象。所有服务请求均使用该策略。 (如果配置了局部也配置了全局，以全局配置为准)
    // @Bean
    // public IRule rules(){
    //     return new RandomRule();
    // }

}